package com.college.resource.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.college.common.constant.ErrorMsg;
import com.college.common.pojo.ao.CarouselImage;
import com.college.common.pojo.ao.CarouselImage;
import com.college.common.pojo.dto.AddCarouselImageDTO;
import com.college.common.pojo.dto.QueryCarouselImageDTO;
import com.college.common.pojo.dto.UpdateCarouselImageDTO;
import com.college.common.pojo.vo.ResultVo;
import com.college.common.utils.ObjectUtil;
import com.college.resource.mapper.CarouselImageMapper;
import com.college.resource.service.CarouselImageService;
import com.github.pagehelper.page.PageMethod;
import org.apache.commons.lang3.ObjectUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 轮播图 服务实现类
 * </p>
 *
 * @author 小C工作室
 * @since 2025-02-22
 */
@Service
public class CarouselImageServiceImpl extends ServiceImpl<CarouselImageMapper, CarouselImage> implements CarouselImageService {
    @Autowired
    private CarouselImageMapper carouselImageMapper;

    @Override
    public List<CarouselImage> queryList(QueryCarouselImageDTO queryCarouselImageDTO) {
        return carouselImageMapper.queryList(queryCarouselImageDTO);
    }

    @Override
    public ResultVo addCarouselImage(AddCarouselImageDTO addCarouselImageDTO) {
        return this.save(addCarouselImageDTO)? ResultVo.success() : ResultVo.fail(ErrorMsg.SYSTEM_ERROR);
    }

    @Override
    public ResultVo updateCarouselImage(UpdateCarouselImageDTO updateCarouselImageDTO) {
        CarouselImage carouselImage = ObjectUtil.objectCopyProperties(updateCarouselImageDTO, CarouselImage.class);
        return this.updateById(carouselImage) ? ResultVo.success() : ResultVo.fail(ErrorMsg.SYSTEM_ERROR);
    }
}
